#ifndef __bsp_can
#define __bsp_can

#include "can.h"

extern CAN_TxHeaderTypeDef   TxHeader;
extern CAN_RxHeaderTypeDef   RxHeader;
extern uint8_t               TxData[8];
extern uint8_t               TxData1[8];
extern uint8_t               RxData[8];
extern uint32_t		TxMailBox;

#define FILTER_BUF_LEN 5


typedef struct{
	int16_t	 	speed_rpm;
  int16_t  	real_current;
  int16_t  	given_current;
  uint8_t  	hall;
	uint16_t 	angle;				//abs angle range:[0,8191]
	uint16_t 	last_angle;	//abs angle range:[0,8191]
	uint16_t	offset_angle;
	int32_t		round_cnt;
	int32_t		total_angle;
	uint8_t		buf_idx;
	uint16_t			angle_buf[FILTER_BUF_LEN];
	uint16_t			fited_angle;
	uint32_t			msg_cnt;
}moto_measure_t;

extern moto_measure_t motor[];

void reset_motor(moto_measure_t* motor);
void get_moto_measure(moto_measure_t *ptr, uint8_t Data[8]);
void get_moto_offset(moto_measure_t *ptr, uint8_t Data[8]);
void set_moto_current(CAN_HandleTypeDef* _hcan,CAN_TxHeaderTypeDef* TxHeader,uint8_t TxData[8] ,uint32_t*	mailbox,int16_t iq1, int16_t iq2, int16_t iq3, int16_t iq4);
void set_moto_current1(CAN_HandleTypeDef* _hcan,CAN_TxHeaderTypeDef* TxHeader,uint8_t TxData[8] ,uint32_t*	mailbox,int16_t iq1, int16_t iq2, int16_t iq3, int16_t iq4);
#endif
